package com.xmtlxx.wms.mapper;

import com.xmtlxx.common.annotation.DataColumn;
import com.xmtlxx.common.annotation.DataPermission;
import com.xmtlxx.common.core.mapper.BaseMapperPlus;
import com.xmtlxx.oms.domain.vo.AreaBiVo;
import com.xmtlxx.oms.domain.vo.CurrentBiVo;
import com.xmtlxx.oms.domain.vo.RegionBiVo;
import com.xmtlxx.oms.domain.vo.StoreBiVo;
import com.xmtlxx.wms.domain.Inventory;
import com.xmtlxx.wms.domain.ProBase;
import com.xmtlxx.wms.domain.bo.InventoryBo;
import com.xmtlxx.wms.domain.bo.SelectInventoryPropertyBo;
import com.xmtlxx.wms.domain.vo.DataVo;
import com.xmtlxx.wms.domain.vo.InventoryVo;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 库存Mapper接口
 *
 * @author xmtlxx
 * @date 2022-08-15
 */
public interface InventoryMapper extends BaseMapperPlus<InventoryMapper, Inventory, InventoryVo> {
    /**
     * 根据条件分页查询库存
     *
     * @param inventory 库存
     * @return Page Inventory
     */
    @DataPermission({
        @DataColumn(key = "tenantName", value = "i.create_by"),
        @DataColumn(key = "deptName", value = "i.dept_id"),
        @DataColumn(key = "userName", value = "i.create_by")
    })
    Page<InventoryVo> selectPageInventoryList(@Param("page") Page<Inventory> page,@Param("inventory") InventoryBo inventory);

    /**
     * 查询库存列表
     *
     * @param inventory 库存
     * @return 库存集合
     */
    @DataPermission({
        @DataColumn(key = "tenantName", value = "i.create_by"),
        @DataColumn(key = "deptName", value = "i.dept_id"),
        @DataColumn(key = "userName", value = "i.create_by")
    })
    List<InventoryVo> selectInventoryList(@Param("inventory") InventoryBo inventory);

    @DataPermission({
        @DataColumn(key = "tenantName", value = "i.create_by"),
        @DataColumn(key = "deptName", value = "i.dept_id"),
        @DataColumn(key = "userName", value = "i.create_by")
    })
    List<InventoryVo> selectInventoryProList(@Param("inventory") InventoryBo inventory);

    InventoryVo selectInventoryVoByID(String id);

    InventoryVo selectInventoryVoByPno(String pno);

    InventoryVo selectInventoryByID(@Param("inventory") InventoryBo inventory);

    InventoryVo selectInventoryByBo(@Param("inventory") InventoryBo inventory);

    Inventory selectInventoryByEnty(@Param("inventory") InventoryBo inventory);

    @DataPermission({
        @DataColumn(key = "tenantName", value = "i.create_by"),
        @DataColumn(key = "deptName", value = "i.dept_id"),
        @DataColumn(key = "userName", value = "i.create_by")
    })
    List<DataVo> selectInventoryByList();

    List<DataVo> selectInventoryByClassfy();

    List<InventoryVo> queryInventoryByList();

    List<StoreBiVo> selectCountByStore(@Param("inventory") InventoryBo inventory);

    List<StoreBiVo> selectCountByAppStore(@Param("inventory") InventoryBo inventory);

    List<AreaBiVo> selectCountByArea(@Param("inventory") InventoryBo inventory);

    List<RegionBiVo> selectCountByRegion(@Param("inventory") InventoryBo inventory);
    List<RegionBiVo> selectCountByAppRegion(@Param("inventory") InventoryBo inventory);
    @DataPermission({
        @DataColumn(key = "deptName", value = "w.dept_id")
    })
    StoreBiVo storeReceivesAndUnPuts(@Param("inventory") InventoryBo inventory);

    StoreBiVo storeUnPuts(@Param("inventory") InventoryBo inventory);
    @DataPermission({
        @DataColumn(key = "deptName", value = "w.dept_id")
    })
    CurrentBiVo countCurrentTotals(@Param("inventory") InventoryBo inventory);

    @DataPermission({
        @DataColumn(key = "deptName", value = "w.dept_id")
    })
    CurrentBiVo countPickupTotals(@Param("inventory") InventoryBo inventory);

    @DataPermission({
        @DataColumn(key = "deptName", value = "s.office_id")
    })
    CurrentBiVo countPoliceTotals();

    @DataPermission({
        @DataColumn(key = "deptName", value = "p.office_id")
    })
    List<RegionBiVo> countPoliceDatas();

    @DataPermission({
        @DataColumn(key = "deptName", value = "d.dept_id")
    })
    List<CurrentBiVo> countRegionTotals();

    @DataPermission({
        @DataColumn(key = "deptName", value = "d.dept_id")
    })
    List<CurrentBiVo> countPoliceDeptTotals();

//    @DataPermission({
//        @DataColumn(key = "deptName", value = "i.dept_id")
//    })
    CurrentBiVo countCurrentOutTotals(@Param("inventory") InventoryBo inventory);

    CurrentBiVo countDatasTotals(@Param("inventory") InventoryBo inventory);

    CurrentBiVo countDatasCurrentTotals(@Param("inventory") InventoryBo inventory);

    @DataPermission({
        @DataColumn(key = "deptName", value = "d.dept_id")
    })
    List<RegionBiVo> countCarTypes(@Param("inventory") InventoryBo inventory);

    @DataPermission({
            @DataColumn(key = "deptName", value = "i.dept_id")
    })
    Page<SelectInventoryPropertyBo> selectInventoryPropertyList(Page<SelectInventoryPropertyBo> page,
                                                                @Param(Constants.WRAPPER) Wrapper<Object> ew);

    List<ProBase> getProBaseList();

    int insertProBase(@Param("proBases") List<ProBase> proBases);
}
